package newcrunch.typography;

/**
 * Convenient class to group rows together so that I can
 * operate on them using loops.
 * 
 * Stores the rows in the table that corresponds to a certain aspect
 * (e.g. space after) that the corresponding keywords (e.g. class)
 * will fall under.
 * 
 * Note that the rows position in the rows array must be the same as
 * the keywords position in the keys array.
 * 
 * @author WL
 */
public class JavaDialogData 
{
    /**
    * Converts a keys array into a strings array
    * @param keywords
    * @return 
    */
    private static String[] convertKeywords(Key... keywords)
    {
        String[] result = new String[keywords.length];
        
        for (int i = 0; i < keywords.length; i++)
            result[i] = keywords[i].toString();
        
        return result;
    }
    
    public static String[] keywordsSpacesAfterSpec = {
        "super", "this", "default"
    };
    
    //array that holds the keywords for checking spaces after
    public static String[] keywordsSpacesAfter = {
        "abstract",
        "assert",
        "boolean",
        "case",
        "catch",
        "char",
        "class",
        "do",
        "else",
        "enum",
        "extends",
        "final",
        "finally",
        "for",
        "goto",
        "if",
        "implements",
        "import",
        "instanceof",
        "interface",
        "native",
        "new",
        "package",
        "private",
        "protected",
        "public",
        "static",
        "strictfp",
        "switch",
        "synchronized",
        "throw",
        "throws",
        "transient",
        "try",
        "void",
        "volatile",
        "while"
    };
    
    public static String[] binaryOperators = 
    {
        Key.AND.toString(), 
        Key.OR.toString(),
        Key.LSHIFT.toString(),             // <<
        Key.RSHIFT.toString(),             // >>
        Key.URSHIFT.toString(),            // >>>    
        Key.LTE.toString(),                // <=
        Key.GTE.toString(),                // >=    
        Key.LSHIFT_EQ.toString(),          // <<=
        Key.RSHIFT_EQ.toString(),          // >>=
        Key.URSHIFT_EQ.toString(),         // >>>=
        "=",
        "+=",
        "-=",
        "*=",
        "/=",
        "&=",
        "|=",
        "^=",
        "%=",
        "?",
        "||",
        "&&",
        "^",
        "==",
        "!=",
        "<",
        ">",
        "+",
        "-",
        "*",
        "/",
        "%"
    };
    
    public static int[] spacesBeforeAfterRows =
    {
      TypoMainTable.SPACES_BEFORE_AFTER_BIN,
      TypoMainTable.SPACES_BEFORE_AFTER_DOT,
      TypoMainTable.SPACES_BEFORE_AFTER_COLON
    };
    
    public static String[][] spacesBeforeAfterKeys = 
    {
        binaryOperators,
        {"."},
        convertKeywords(Key.COLON_OPERATOR)
    };
    
    public static int[] spacesBeforeRows =
    {
        TypoMainTable.SPACES_BEFORE_COLON,
        TypoMainTable.SPACES_BEFORE_COMMA,
        TypoMainTable.SPACES_BEFORE_SEMI,
        TypoMainTable.SPACES_BEFORE_LPAREN,
        TypoMainTable.SPACES_BEFORE_RPAREN,
        TypoMainTable.SPACES_BEFORE_RBRACKET,
        TypoMainTable.SPACES_BEFORE_RANGULAR
    };
    
    public static String[][] spacesBeforeKeys = 
    {
        convertKeywords(Key.COLON_LABEL),
        {","},
        {";"},
        convertKeywords(Key.LPAREN_METHOD),
        {")"},
        {"]"},
        convertKeywords(Key.RTYPE)
    };
    
    public static int[] spacesAfterRows = 
    {  
        TypoMainTable.SPACES_AFTER,
        TypoMainTable.SPACES_AFTER_SPEC,
        TypoMainTable.SPACES_AFTER_COMMA,
        TypoMainTable.SPACES_AFTER_SEMIFOR,
        TypoMainTable.SPACES_AFTER_LPAREN,
        TypoMainTable.SPACES_AFTER_LBRACKET,
        TypoMainTable.SPACES_AFTER_LANGULAR,
        TypoMainTable.SPACES_AFTER_CAST
    };
    
    public static String[][] spacesAfterKeys = 
    {
        keywordsSpacesAfter,
        keywordsSpacesAfterSpec,
        {","},
        convertKeywords(Key.SEMICOLON_FOR),
        {"("},
        {"["},
        convertKeywords(Key.LTYPE),
        convertKeywords(Key.RPAREN_CAST)
    };
    
    public static int[] identifierRows =
    {
        TypoMainTable.VARIABLE_NAME,
        TypoMainTable.METHOD_NAME,
        TypoMainTable.CLASS_INTERFACE_NAME,
        TypoMainTable.CONSTANT_NAME
    };
    
    public static int[] blankInfoRows =
    {
      TypoMainTable.AFTER_HEADER,
      TypoMainTable.BTW_CLASSES,
      TypoMainTable.BTW_METHODS,
      TypoMainTable.BEFORE_COMMENTS,
      TypoMainTable.BTW_FIELDS_METHOD
    };
    
    public static String[] unaryPrefix =
    {
        Key.PLUS_PREFIX.toString(),
        Key.PLUSPLUS_PREFIX.toString(),
        Key.SUB_PREFIX.toString(),
        Key.SUBSUB_PREFIX.toString()
    };
    
    public static String[] unaryPostfix =
    {
        Key.PLUSPLUS_POSTFIX.toString(),
        Key.SUBSUB_POSTFIX.toString()
    };
}
